﻿


Public Class Filter
    'Shared :
    Private Shared _DefaultFilter As Filter
    Public Shared ReadOnly Property DefaultFilter As Filter
        Get
            Return _DefaultFilter
        End Get
    End Property
    Shared Sub New()
        _DefaultFilter = New Filter With {.Name = "Already Compressed", .Method = Zip.CompressionMethod.None, .Level = Zlib.CompressionLevel.None}
        _DefaultFilter.FilteredExtensions.AddRange({".zip", ".chm", ".exe"})
        For i As Integer = 1 To 99
            _DefaultFilter.FilteredExtensions.Add(String.Format(".z{0:D2}", i))
        Next
    End Sub
    'Ctor :
    Public Sub New()
        Name = "Filter"
        FilteredExtensions = New List(Of String)
        Method = Zip.CompressionMethod.None
        Level = Zlib.CompressionLevel.None
    End Sub
    'Fields :
    Public Property Name As String
    Public Property FilteredExtensions As List(Of String)
    Public Property Method As Zip.CompressionMethod
    Public Property Level As Zlib.CompressionLevel
    'Apply To ZipEntry :
    Public Sub ApplyToZipEntry(ByVal ze As Zip.ZipEntry)
        If FilteredExtensions.Contains(IO.Path.GetExtension(ze.FileName)) = True Then
            ze.CompressionMethod = _Method
            ze.CompressionLevel = _Level
        End If
    End Sub
End Class
